import requests
import json

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'
}
num = int(input("你想要几页？"))

for i in range(1,num+1):
    url0 = 'http://125.35.6.84:81/xk/itownet/portalAction.do?method=getXkzsList'

    data = {
        'on': 'true',
        'page': i,
        'pageSize': '15',
        'productName': '',
        'conditionType': '1',
        'applyname': ''
    }
    result = requests.post(url=url0,headers=headers,data=data).json()
    result = result['list']
    print(result)
    for each in result:
        id = each['ID']
        datas = {'id': id}
        url1 = 'http://125.35.6.84:81/xk/itownet/portalAction.do?method=getXkzsById'
        page = requests.post(url=url1,headers=headers,data=datas ).json()
        fp = open('./hzp.json','a',encoding='utf-8')
        json.dump(page,fp=fp,ensure_ascii=False)
